package com.linh.trade.algo;

import java.util.List;

import com.linh.trade.data.Point;

public class WindowMoverByTime implements WindowMover {

	private long window;

	public WindowMoverByTime(long window) {
		super();
		this.window = window;
	}

	public void move(List<Point> pointsInWindow, long latestTime) {
		while (pointsInWindow.size() > 0) {

			Point p = pointsInWindow.get(0);
			long timeDiff = latestTime - p.getNano();
			if (timeDiff > window) {
				// remove since point moved out of window
				pointsInWindow.remove(0);
			} else {
				// stop
				break;
			}
		}

	}

}
